package com.longge;

public class HammingDistance {

    public int hammingDistance(int x, int y) {

        int r = x^y;
        char[] chars = Integer.toBinaryString(r).toCharArray();
        int ans = 0;
        for (char aChar : chars) {
            if (aChar=='1'){
                ans++;
            }
        }
        return ans;

    }
}
